/*
	It started to be written by Roosevelt de Lima Sardinha, in March, 17th, 2010.
	Rootabs is a javascript component for creating and managing tabs in a web page.
*/

function tab(id, properties)
{
	this.id = id;
	this.title = properties.title;
	this.panelCSS = properties.panelClass ? properties.panelClass : 'default-panels-css';
	this.tabCSS = properties.tabCSS ? properties.tabCSS : 'default-tabs-css';
	this.tabSelectedCSS = properties.tabSelectedCSS ? properties.tabSelectedCSS : 'default-tabs-selected-css';
	
	var tabLi = document.createElement('li');
	var tabA = document.createElement('a');
	var tabSpan = document.createElement('span');
	var panel = document.createElement('div');
	
	tabSpan.innerHTML = this.title;
	
	tabA.appendChild(tabSpan);
	tabLi.appendChild(tabA);
	tabLi.className = this.tabCSS;
	panel.className = this.panelCSS;
	
	this.tab = tabLi;
	this.panel = panel;
	this.panel.style.display = 'none';
	this.selected = false;
	
	this.select = function()
	{
		this.selected = true;
		this.tab.className += ' ' + this.tabSelectedCSS;
		this.panel.style.display = '';
	}
	
	this.unselect = function()
	{
		this.selected = false;
		this.tab.className = this.tabCSS;
		this.panel.style.display = 'none';
	}
}